// get the client
const mysql = require('mysql2');

// create the connection to database
const connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: 'root',
  database: 'bw2010ab-koa-demo4'
});


module.exports = (sql) => {
  return new Promise((resolve, reject) => {
    connection.query(
      sql,
      function (err, results, fields) {
        if (err) {
          reject(err);
          return;
        }
        resolve(results)
      }
    );
  })
}